import { createRouter, createWebHashHistory } from 'vue-router'

const routes = [
  {
    path: '/',
    redirect: '/home'
  },
  {
    path: '/home',
    name: 'Home',
    component: () => import('@/views/home')
  },
  {
    path: '/singer',
    name: 'Singer',
    component: () => import('@/views/singer')
  },
  {
    path: '/album',
    name: 'Album',
    component: () => import('@/views/album')
  },
  {
    path: '/toplist',
    name: 'Toplist',
    component: () => import('@/views/toplist')
  },
  {
    path: '/category',
    name: 'Category',
    component: () => import('@/views/category')
  },
  {
    path: '/radio',
    name: 'Radio',
    component: () => import('@/views/radio')
  },
  {
    path: '/mvlist',
    name: 'Mvlist',
    component: () => import('@/views/mvlist')
  },
  {
    path: '/album_mall',
    name: 'Album_mall',
    component: () => import('@/views/album_mall')
  },
  {
    path: '/playlist',
    name: 'Playlist',
    component: () => import('@/components/playlist')
  },
  {
    path: '/player',
    name: 'player',
    component: () => import('@/components/player')
  },
]
// 每次做路由切换时，始终回到最顶部

const router = createRouter({
  history: createWebHashHistory(process.env.BASE_URL),
  routes
})

router.afterEach((to, from, next) => {
  window, scrollTo(0, 0)
})
export default router
